
using System;

namespace stefc.geo.lib
{

	/// <summary>
	/// Polar coordinate
	/// </summary>
	public class Polar
	{
		private readonly double angle;
		private readonly double distance;
		
		private static volatile Polar zero;
		
		public Polar(double angle, double distance)
		{
			this.angle=(angle<0) ? angle + 2*Math.PI : angle;
			this.distance=distance;
		}
			
		public double Angle { get { return this.angle; } }
			
		public double Distance { get { return this.distance; } }
		
		public override string ToString ()
		{
			return string.Format("[Polar: Angle={0}, Distance={1}]", Angle, Distance);
		}
		
		public static Polar Zero 
		{
			get 
			{
				if(zero==null)
					zero=new Polar(0,0);
				return zero;
			}
		}
	}
}
